import {MailOutlined, SearchOutlined} from '@ant-design/icons';
import '@umijs/max';
import {Button} from "antd";
import SearchModal from "@/components/SearchModal/SearchModal";
import {useState} from "react";
import {history} from "@@/core/history";

export const Question = () => {
  const [visible, setVisible] = useState<boolean>(false);
  const {location} = history;
  const cancelVisible = () => setVisible(!visible)
  const openEmil = () => {
    const email = "admin@example.com";
    const subject = "SubjectHere";
    const body = "MessageBodyHere";
    // window.location.href = `mailto:${email}?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(body)}`;
    window.location.href = `mailto:${email}`;

  }
  return (
    <>
      {/*全文搜索*/}
      {
        location.pathname === '/' && <>
          <Button
            shape="circle"
            onClick={cancelVisible}
            icon={<SearchOutlined/>}>
          </Button>
          {/*搜索模态框*/}
          <SearchModal visible={visible} onCancel={cancelVisible}/>

        </>
      }
      <Button
        style={{marginLeft: 24}}
        shape="circle"
        icon={<MailOutlined/>}
        onClick={openEmil}
      >
      </Button>
    </>

  )

};
